package com.apkplug.test.bundle;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import org.apkplug.Bundle.BundleInstance;
import org.osgi.framework.BundleContext;

/**
 * Created by bshao on 10/29/15.
 */
public class BundleContextHolder implements BundleInstance {

    private static volatile BundleContextHolder sInstance;

    @NonNull
    public static BundleContextHolder getInstance() {
        if (sInstance == null) {
            synchronized (BundleContextHolder.class) {
                if (sInstance == null) {
                    sInstance = new BundleContextHolder();
                }
            }
        }
        return sInstance;
    }

    private BundleContext mBundleContext;

    @Override
    @Nullable
    public BundleContext getBundleContext() {
        return mBundleContext;
    }

    @Override
    public void setBundleContext(@Nullable BundleContext bundleContext) {
        mBundleContext = bundleContext;
    }
}
